package com.demo.coretech.innerclass;

import java.util.Random;

/**
 * @Authors：gaoyang
 * @CreateTime：2021/11/27 11:42
 * @Description：todo
 */
public class StaticInnerClassTest {

    public static void main(String[] args) {
        double[] d = new double[20];
        for (int i=0;i<d.length;i++){
            d[i] = new Random().nextInt(100);
        }
        ArrayAlg.Pair p = ArrayAlg.minmax(d);
    }
}
class ArrayAlg{
    public static class Pair{
        private double first;
        private double second;

        public double getFirst() {
            return first;
        }

        public double getSecond() {
            return second;
        }

        public Pair(double first, double second) {
            this.first = first;
            this.second = second;
        }
    }
    public static Pair minmax(double[] val){
        double min = Double.POSITIVE_INFINITY;
        double max = Double.NEGATIVE_INFINITY;
        for (double v:val){
            if (min>v){
                min = v;
            }
            if (max<v){
                max = v;
            }
        }
        return new Pair(min,max);
    }
}